home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / SYMBMATH.H13 < prev    next >
Text File  |  1993-11-07  |  3KB  |  54 lines

  1.          3.3.3  Assignment Statements
  2.         The assignement in SymbMath language is similar to assignment in
  3. such language as PASCAL.
  4.         An assignment operator is   :=
  5.     The assignment statement specifies that a new value of expr2 
  6. be assigned to expr1, and saved into memory. The form of the assignment
  7. statements is
  8.  
  9.         expr1 := expr2
  10.  
  11.         You can use assignment for storing result.
  12.         You can assign the result of calculation or any formula to a
  13. variable with a command like:    X := SIN(4.2).
  14.         The assignemts are useful for long calculations.  You can save
  15. yourself a lot of recalculations by always storing the results of your
  16. calculations in your own variables instead of leaving them in the default
  17. variable last.
  18.         You can destroy the assignmemt to X with the command clear(X). If 
  19. X stored a large list, you could regain a considerable amount of memory by
  20. clearing X. Also, since a variable and a function can have the same name,
  21. you can clear a variable p, not a function p(x).
  22.     The assignment operator is also used in the definition of
  23. a function or procedure.
  24.         Variables can be used in function definitions, and that leads to an
  25. important difference between functions and variables.  When a variable is
  26. defined, all terms of the definition are evaluated.  When a function is
  27. defined, its terms are not evaluated; they are evaluated when the function 
  28. is evaluated.  That means that if a component of the function definition is
  29. changed, that change will be reflected the next time the function is
  30. evaluated.
  31.  
  32.     e.g. 
  33. IN:  p:=2+3     # 2+3 is evaluated at the time of assignment,
  34.             # p is assigned with 5.
  35. OUT: p := 5
  36. IN:  p(x):=2+3  # 2+3 is evaluated when the value of p(x) is requested,  
  37.             # p(x) is assigned with 2+3.
  38. OUT: p(x) := 2+3
  39.  
  40. If the left hand side of the assignment is a variable, it is the immediate
  41. assignment (i.e. expr2 is evaluated at the time of assignment); if the
  42. left hand side is a function, it is the delayed assignment (i.e. expr2 is
  43. evaluated when the value of expr1 is requested).
  44.         You can force all the components of a function to be evaluated when
  45. the function is defined by preceding the function with the command eval():
  46.                 f(x_) := eval(2+3)   # f(x_) is assigned with 5
  47.     Note that not only a variable but also any expression can be
  48. assigned. e.g. x:=2, sin(x)/cos(x) := tan(x), a>0 := 1.
  49.     Clear a variable, function or expression from assignment by
  50.  
  51.         clear(x)          # clear x from assignment.
  52.         clear(f(x))       # clear f(x) from assignment.
  53.         clear(a>0)        # clear a>0 from assume(a>0).
  54.